<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');


//get variables passed in
$availability_id = mysql_real_escape_string(strip_tags($_POST['id']));
$instructor_id = mysql_real_escape_string(strip_tags($_POST['iid']));
$q = "SELECT * FROM instructors WHERE id = '$instructor_id'";
$r = mysql_query($q);
$row = mysql_fetch_assoc($r);
$instructor_fname = $row['first_name'];
$instructor_lname = $row['last_name'];
$starttime = mysql_real_escape_string(strip_tags($_POST['start']));
$endtime = mysql_real_escape_string(strip_tags($_POST['end']));


echo "<h1>Edit Availability for $instructor_fname $instructor_lname</h1>";


//select statement
$query="UPDATE instructor_availability 
SET start_time='$starttime', end_time='$endtime'
WHERE id='$availability_id'";

$result=mysql_query($query);

//close
mysql_close();

if ($result)
{
	echo "Timeslot has been successfully updated!";
	echo "<br />";
}
else
{
	echo "Timeslot was NOT able to be updated at this time!";
	echo "<br />";
}

echo "<p>";
	echo "<a href='update_availability.php?id=$instructor_id&fname=$instructor_fname&lname=$instructor_lname'>&lt;&lt; Back to Instructors Portal</a><br />";
echo "</p>";
?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>